Skip to content

Various documentation improvements. #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 14, 2025
Merged

Conversation

stephentyrone
Copy link
Member

@stephentyrone stephentyrone commented Jul 17, 2023

Added some docc catalogs and articles, fixed a bunch of minor errors, all that good stuff. More work needed.

The `Complex` type is generic over an associated `RealType`; complex numbers
are represented as two `RealType` values, the real and imaginary parts of the
number.
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For broader compatibility with various Markdown viewer implementations, would it be possible to add an extra line before and after such code blocks?

Comment on lines +47 to +68
let a: Double = 1
let b = 2*a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is easier to follow along the arithmetic examples (especially the next one), if this unsupported heterogeneous operator example would re-use the example from C above (and below) – I may be wrong.

Suggested change
let a: Double = 1
let b = 2*a
import ComplexModule
let r: Double = 1.0
let z = Complex<Double>(0, 2)
let w = r + z // ❌

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is to provide an example that would break if we did have a heterogeneous operator.

Copy link
Contributor

@markuswntr markuswntr Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right - my example is misleading. Does it make sense to adjust the other two examples then, and make them use multiplication over addition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to rearrange stuff to clarify it a little bit, might revisit later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This is potentially useful to identify some bugs, but there are also algorithms (notably Kahan summation) that can be written in terms of fast2sum but would fail this check. Rework documentation to account for the change.
Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! Added a few notes but this is overall a huge improvement 👏🏻👏🏻👏🏻

@@ -12,26 +12,29 @@
extension BinaryInteger {
/// `self` divided by `other`, rounding the result according to `rule`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// `self` divided by `other`, rounding the result according to `rule`.
/// Returns the result of dividing this value by `other`, rounding the result
/// according to `rule`.

or (preferred):

Suggested change
/// `self` divided by `other`, rounding the result according to `rule`.
/// Returns the result of dividing this value by the given value, rounding
/// the result according to specified rule.

`ElementaryFunctions` (so all the usual math functions are
available).
A complex number type represented by its real and imaginary parts, and equipped
with the usual arithmetic operators and math functions.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

This commit _also_ relaxes the constraint on Augmented algorithms from Real to FloatingPoint. It's worth calling out that fastTwoSum does not work with decimal floating-point types, so the unordered `Augemented.sum(_:_:)` now has a radix check and calls into the ordered twoSum function instead for Decimal. This makes more sense that a `BinaryFloatingPoint` constraint, as otherwise generic code written against Real or FloatingPoint would have to do the check at every call site.
@stephentyrone
Copy link
Member Author

API break reported by tests is not actually an API break, because Real refines FloatingPoint (and we haven't yet tagged a release with those API anyway).

@stephentyrone stephentyrone merged commit a50d957 into apple:main Aug 14, 2025
22 of 24 checks passed
@stephentyrone stephentyrone deleted the docc-stuff branch August 14, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants